package com.github.admin.edu.security.jwt.client.configuration;

import com.github.admin.edu.security.jwt.client.interceptor.FeignClientResultInterceptor;
import com.github.admin.edu.security.jwt.client.interceptor.ServiceResultAuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 权限管理设置
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-7-18
 */
@Configuration
public class ClientAuthConfiguration implements WebMvcConfigurer {



    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(getServiceResultAuthInterceptor())
                .addPathPatterns("/rest/api/oauth/**")
                .excludePathPatterns("/rest/api/oauth/token","/rest/api/oauth/authentication");
    }


    @Bean
    public ServiceResultAuthInterceptor getServiceResultAuthInterceptor(){

        return new ServiceResultAuthInterceptor();
    }

    @Bean
    public FeignClientResultInterceptor getFeignClientResultInterceptor(){
        return new FeignClientResultInterceptor();
    }

}
